const express = require('express')
const path = require('path');
const bodyParser = require('body-parser');
const app = express()
app.use(bodyParser.json());
const loginRouter = require('./routers/login');
const register  = require('./routers/register')
//设置服务器跨域权限
// app.use(function (req, res, next) {
//     res.header("Access-Control-Allow-Origin", "*");
//     res.header("Access-Control-Allow-Headers", "X-Requested-With");
//     res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
//     next();
// });
var cors = require('cors');
app.use(cors({
    origin:['http://localhost:8099'],
    methods:['GET','POST'],
    alloweHeaders:['Conten-Type', 'Authorization']
}));
app.use('/login', loginRouter);
app.use('/register', register);
app.listen(3000,()=> {
    console.log("3000");
})
module.exports = app;